/**
 * Project of Vehicle Routing Problem with Time Windows implements 
 * some of well-known algorithms for solving VRPTW and presents new 
 * one.
 *
 * @author Michal Drobny  
 */

package logic.restriction;

import logic.restriction.enumeration.ChangeCycleVariant;
import logic.restriction.enumeration.IterationType;

/**
 * Represents the abstract Restriction for solving Vehicle Routing Problem. It
 * can be various types, for example Capacity Restriction for Vehicle or
 * Destination. Every Restriction has to have methods for updating the given
 * restriction during executing current VRP algorithm. Usually it is a
 * iterate(Object..., IterationType) method, which can update the restriction
 * parametres depending on the provided objects - it means, that the given route
 * will be modified (updated) and the restriction can (should) be modified too.
 * We can use the canIterate(Object..., IterationType) method, which do the same
 * as iterate, but returns only the boolean value. It is suitable if we are
 * considerating whether add the Destination to route or not. In that case we
 * have more vehicles suitable for solving the problem, we can use a method
 * nexCycle, which provides the same functionality as reset(), but sets a new
 * vehicle for current iterating.
 * 
 * @author Michal Drobny
 * @date 17.10.2014
 */
public abstract class Restriction {

	/**
	 * This method can update the restriction by information gained by given
	 * params. This method is usually called when the route will be modified
	 * (updated) during we are solving VRP.
	 *
	 * 
	 * @params type The type of iteration - it means how we are building cycles
	 *         and how we are using the restriction adapter in vehicle routing
	 *         problem.
	 * 
	 * @param params
	 *            The params, which can be useful for updating the route
	 */
	public abstract void iterate(IterationType type, Object... params);

	/**
	 * This method have the same functionality as iterate(IterationType,
	 * Object...) method, but returns boolean value, whether the route can be
	 * modified depending on the params.If not, there are some unpassed
	 * restrictions.
	 * 
	 * @params type The type of iteration - it means how we are building cycles
	 *         and how we are using the restriction adapter in vehicle routing
	 *         problem.
	 * @param params
	 *            The params, which can be useful for updating the route
	 * @return Whether the route can be modified depending on the params
	 */
	public abstract boolean canIterate(IterationType type, Object... params);

	/**
	 * This method only checks the logic of canNewCycle(ChangeCycleVariant,
	 * Object...) method. It means whether that method can be applied.
	 * 
	 * @param type
	 *            The type of cycle changing. Depending on this type we can
	 *            modify current restriction.
	 * @param params
	 *            The params, which can be useful for updating the route
	 * @return Whether method newCycle(...) for specified params can be applied
	 */
	public abstract boolean canNewCycle(ChangeCycleVariant type,
			Object... params);

	/**
	 * This method has the same functionality as reset() method, it means that
	 * sets all values of this restriction like it was in initial state, but in
	 * that state there can be some different values depending on the vehicle
	 * changing. If we have more vehicles to solve VRP, then we should use
	 * newCycle() method.
	 * 
	 * @param type
	 *            The type of cycle changing. Depending on this type we can
	 *            modify current restriction.
	 * @param params
	 *            The params, which can be useful for updating the route
	 */
	public abstract void newCycle(ChangeCycleVariant type, Object... params);

	/**
	 * This method resets this Restriction to initial state - it means like it
	 * was created. It sets all fields to initial values.
	 */
	public abstract void reset();
}